<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>路由传参</title>
</head>
<script src="vue.js"></script>
<script src="vue-router.js"></script>
<body>
    <div id="app">
        <router-link to="/login?id=9&level=2">登录</router-link>
        <router-view></router-view>
    </div>

    <script>
        var login = {
            template:'<h1>这是登录组件模板{{this.id}} + {{this.level}}</h1>',
            data:function(){
                return{
                    id:'',
                    level:''
                }
            },
            created(){
                console.log(this);
                console.log(this.$route.query.id+ ":" + this.$route.query.level);
                this.id=this.$route.query.id;
                this.level=this.$route.query.level
            },
        };
        const router = new VueRouter({
            routes:[
                {path:'/login',component:login},
            ]
        })
        var vm = new Vue({
            el:'#app',
            router:router,
        })
    </script>
</body>
</html>